import axios from './index'

// const preUrl = ''


// 获取需求列表
const getDemandList = {
  p: [`get,demand/list`],
  r: params => {
    return axios.get(`/demand/list`, {
      params
    })
  }
}

// 获取需求详情
const getDemandDetails = {
  p: [`get,demand/info/*`],
  r: params => {
    return axios.get(`/demand/info/${params.id}/${params.department}`)
  }
}

// 新增需求
const addDemand = {
  p: [`post,demand/create`],
  r: params => {
    // axios.defaults.headers['Content-Type'] = 'multipart/form-data'
    return axios.post(`/demand/create`, params)
  }
}

// 需求管理
const modifyDemand = {
  p: [`put,demand/update`],
  r: params => {
    return axios.put(`/demand/update`, params)
  }
}

// 部门移交
const handoverDemand = {
  p: [`post,demand/list`],
  r: params => {
    return axios.post(`/demand/handover`, params)
  }
}

// 版本移交
const pushVerison = {
  p: [`post,demand/commit`],
  r: params => {
    return axios.post(`/demand/commit`, params)
  }
}

// 获取项目列表
const getProjectList = {
  p: [`get,demand/project`],
  r: () => {
    return axios.get(`/demand/project`)
  }
}

// 获取部门列表
const getDepartmentList = {
  p: [`get,demand/department`],
  r: () => {
    return axios.get(`/demand/department`)
  }
}

// 获取公众号列表
const getAreaList = {
  p: [`get,demand/area`],
  r: () => {
    return axios.get(`/demand/area`)
  }
}

// 获取统计数据
const getStatistics = {
  p: [`get,department/statistical`],
  r: () => {
    return axios.get(`department//statistical`)
  }
}

// 获取统计数据
const getDemandListDP = {
  p: [`get,department/list`],
  r: params => {
    return axios.get(`department//list`, {
      params
    })
  }
}


// 删除需求
const delDemand = {
  p: [`delete,demand/delete`],
  r: params => {
    return axios.delete(`/demand/delete/${params.id}`)
  }
}

// 搜索需求
const searchDemand = {
  p: [`get,demand/condition`],
  r: params => {
    return axios.get(`/demand/condition`, {
      params
    })
  }
}


// 搜索需求
const searchFinished = {
  p: [`get,demand/condition`],
  r: params => {
    return axios.get(`/demand/condition`, {
      params
    })
  }
}

// 获取对应公众号的项目
const getAreaProjects = {
  p: [`get,demand/areaProject`],
  r: params => {
    return axios.get(`/demand/areaProject/${params.areaId}`, {
      params
    })
  }
}


export {
  getDemandList,
  addDemand,
  modifyDemand,
  getDemandDetails,
  handoverDemand,
  pushVerison,
  getProjectList,
  getDepartmentList,
  getAreaList,
  getStatistics,
  getDemandListDP,
  delDemand,
  searchDemand,
  searchFinished,
  getAreaProjects
}